//
//  playRecordViewController.m
//  One Construction
//
//  Created by apple on 2019/9/7.
//  Copyright © 2019 apple. All rights reserved.
//

#import "playRecordViewController.h"
#import "secondTableViewCell.h"
@interface playRecordViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *dataArr;
@end

@implementation playRecordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0];
    
    self.navigationItem.title = @"播放记录";
    [self requestData];
    [self.view addSubview:self.tableView];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 120;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cellid = @"recoedCell";
    secondTableViewCell *cell  = [tableView dequeueReusableCellWithIdentifier:cellid];
    cell.backgroundColor  =[UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0];
    //    secondModel *model = self.dataArr[indexPath.row];
    
    [cell.headImgView sd_setImageWithURL:[NSURL URLWithString:self.dataArr[indexPath.row][@"pic"]]];
    cell.topLable.text = self.dataArr[indexPath.row][@"bt"];
    cell.lesonImgView.hidden = YES;
//    cell.studyLable.text = [NSString stringWithFormat:@"%@学习人数",self.dataArr[indexPath.row][@"xx_rs"]];
    return cell;
}

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, AppNavitionHright, ScreenWidth, ScreenHeight-TabbarSafetyZone) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor =  [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0];
        [_tableView registerClass:[secondTableViewCell class] forCellReuseIdentifier:@"recoedCell"];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        
    }
    return _tableView;
    
}
- (void)requestData{
    NSDictionary *dic = @{
                          @"user_id":[User sharedUUser].user_id
                          };
    __weak __typeof__ (self)WeakSelf = self;
    [CZNetWork post:@"https://i.zhongjianedu.com/ios.php/104/sy/VideoCacheList" params:dic success:^(id success) {
        NSLog(@"nn%@",success);
        
        [WeakSelf.dataArr removeAllObjects];
        NSArray *arry = success[@"data"];
        for (int i = 0 ; i<arry.count; i++) {
            [WeakSelf.dataArr addObject:arry[i]];
            //            secondModel *model = [secondModel mj_objectWithKeyValues:arry[i]];
            //            [wealSelf.dataArr addObject:model];
        }
        
        [WeakSelf.tableView reloadData];
        
        
    } failure:^(NSError *error) {
        
    }];
    
    
    
}
- (NSMutableArray *)dataArr{
    if (!_dataArr) {
        _dataArr = [[NSMutableArray alloc]init];
    }
    return _dataArr;
}


@end
